
#include "class.h"

Class::Class(Id * name, Id * subClass, Constant * instanceVariablesNames,	Constant * classVariableNames, Constant * poolDictionaries)
{
	c_instanceVariablesNames=instanceVariablesNames;
	c_classVariableNames=classVariableNames;
	c_poolDictionaries=poolDictionaries;
	c_name=name;
	c_subClass=subClass;
}

void Class::addMethodList(AbstractNode * methodList)
{
	c_methodList=methodList;
}

void Class::write(GraphStream * s)
{
	this->accept(s);

	fprintf(s->stream,"\tnode_%d [label=\"Class \" shape=\"rectangle\"]\n", this->number());
	
	c_name->write(s);
	fprintf(s->stream,"\tnode_%d -> node_%d [label=\"name\"]\n",this->number(),c_name->number());

	c_subClass->write(s);
	fprintf(s->stream,"\tnode_%d -> node_%d [label=\"sub class\"]\n",this->number(),c_subClass->number());

	c_instanceVariablesNames->write(s);
	fprintf(s->stream,"\tnode_%d -> node_%d [label=\"instance variables names\"]\n",this->number(),c_instanceVariablesNames->number());

	c_classVariableNames->write(s);
	fprintf(s->stream,"\tnode_%d -> node_%d [label=\"class variables names\"]\n",this->number(),c_classVariableNames->number());

	c_poolDictionaries->write(s);
	fprintf(s->stream,"\tnode_%d -> node_%d [label=\"pool dictionaries\"]\n",this->number(),c_poolDictionaries->number());

	c_methodList->write(s);
	fprintf(s->stream,"\tnode_%d -> node_%d [label=\"method list\"]\n",this->number(),c_methodList->number());
}

Class::~Class(void)
{
	delete c_name;
	delete c_subClass;
	delete c_methodList;
	delete c_instanceVariablesNames;
	delete c_classVariableNames;
	delete c_poolDictionaries;
}